const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');


module.exports = {
  resolve: {
    alias: {'@': '..',},
    extensions: ['.js', '.jsx']
  },
  module: {
    rules: [
      {
        test: /\.js/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader'
        }
      }, {
        test: /\.(png|jpe?g|gif|svg|docx)(\?.*)?$/,
        use: [
          {
            loader: 'url-loader', //绝对路径原名引入，js和css中本地打包没问题，名字加入哈希值直接引入，js不会打包成哈希值
            options: { //js里不能绝对路径引入，必须import或者require不然不会走loader， css里绝对路径引入
              limit: 10000,
              name: '[name].[hash:6].[ext]', //哈希值解决图片缓存问题
              outputPath: 'images',
              esModule: false
              // publicPath: '/images'
            }
          }
        ]
      },
    ]
  },
}
